<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of PersonWorkclass
 *
 * @author adhamhelal
 */
class PersonWorkPanel extends QPanel{
	protected $mctPerson;
        protected $mctAddress;

        //Controls
        protected $txtOrg;
        protected $txtWorkPhone;
        protected $txtWorkPhone2;
        protected $txtWorkPhone3;
        protected $txtWorkFax;
        protected $txtWorkMobile;
        protected $txtWorkMobile2;
        protected $txtWorkEmail;
        protected $txtWorkEmail2;
        protected $txtWebsite;
        protected $authSys;
        public function txtOrg_Change($strParameter){
                return $this->authSys->AutoList_MyOrgList($strParameter, "Name");
	    }

       public function __construct($objParentObject, $mctPerson, $mctAddress, $strControlId = null) {
                // Call the Parent
                try {
                        parent::__construct($objParentObject, $strControlId);
                } catch (QCallerException $objExc) {
                        $objExc->IncrementOffset();
                        throw $objExc;
                }
            $this->authSys = new Perm();
            $this->authSys->IsAuthenticated(true);
                // Setup Template
                $this->strTemplate = __DOCROOT__.__PERSON__ .  '/tpl/qpanel.tpl.php';
                // Set the Person Meta Conrol
                $this->mctPerson = $mctPerson;
                $this->mctAddress=$mctAddress;
                
                
                // Call MetaControl's methods to create qcontrols based on ComSchool's data fields
                $this->txtOrg = $this->mctPerson->txtOrg_Create();
                $this->txtOrg->SetParentControl($this);

                $this->txtOrg->Name =  "<a href='". __ORG__ . "/Organization_edit.php' target='_blank'> Organzation</a>";
                $this->txtOrg->SetParentControl($this);

                $this->txtWorkPhone = $this->mctAddress->txtWorkPhone_Create();
                $this->txtWorkPhone->SetParentControl($this);

                $this->txtWorkPhone2 = $this->mctAddress->txtWorkPhone2_Create();
                $this->txtWorkPhone2->SetParentControl($this);

                $this->txtWorkPhone3 = $this->mctAddress->txtWorkPhone3_Create();
                $this->txtWorkPhone3->SetParentControl($this);

                $this->txtWorkMobile = $this->mctAddress->txtWorkMobile_Create();
                $this->txtWorkMobile->SetParentControl($this);

                $this->txtWorkMobile2 = $this->mctAddress->txtWorkMobile2_Create();
                $this->txtWorkMobile2->SetParentControl($this);

                $this->txtWorkFax = $this->mctAddress->txtWorkFax_Create();
                $this->txtWorkFax->SetParentControl($this);

                $this->txtWorkEmail = $this->mctAddress->txtWorkEmail_Create();
                $this->txtWorkEmail->SetParentControl($this);

                $this->txtWorkEmail2   = $this->mctAddress->txtWorkEmail2_Create();
                $this->txtWorkEmail2->SetParentControl($this);

                $this->txtWebsite = $this->mctAddress->txtWebsite_Create();
                $this->txtWebsite->SetParentControl($this);
    }

    public function Validate() {
        $Error = false;
        $blnToReturn = true;

        if ( ValidateNumberCtl($this->txtWorkPhone) )   $Error=true;
        if ( ValidateNumberCtl($this->txtWorkPhone2) )  $Error=true;
        if ( ValidateNumberCtl($this->txtWorkPhone3) ) $Error=true;
        if ( ValidateNumberCtl($this->txtWorkMobile) )  $Error=true;
        if ( ValidateNumberCtl($this->txtWorkMobile2) ) $Error=true;
        if ( ValidateNumberCtl($this->txtWorkFax) ) $Error=true;
        if ( ValidateEmailCtl($this->txtWorkEmail) )   $Error=true;
        if ( ValidateEmailCtl($this->txtWorkEmail2) )   $Error=true;

        $blnFocused = false;
        foreach ($this->GetChildControls()  as $objControl) {
              if ( !is_null($objControl->Warning) )  {
                    if (!$blnFocused) {
                            $objControl->Focus();
                            $blnFocused = true;
                    }
                    $objControl->Blink();
              }
        }
        return $Error;
    }




}
?>

